package com.ruge.core.domain;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import org.springframework.data.domain.Pageable;

/**
 * @author ruge.wu
 * @since 2022/2/9 17:07
 */
@Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(description = "基础请求数据")
public class PageRequest {
    @ApiModelProperty(value = "起始页码", example = "0")
    private Integer page = 0;
    @ApiModelProperty(value = "每页数据", example = "15")
    private Integer limit = 15;

    public Pageable getPageable() {
        return org.springframework.data.domain.PageRequest.of(page, limit);
    }

    public Integer getMysqlStart() {
        return page * limit;
    }

    public Integer getMysqlEnd() {
        return (page + 1) * limit;
    }

    public Integer getOracleStart() {
        return page * limit;
    }

    public Integer getOracleEnd() {
        return page * limit;
    }
}
